package com.sunyy.codegenerator.controller;

import com.sunyy.codegenerator.dto.codeGenerator.GenerateDto;
import com.sunyy.codegenerator.dto.codeGenerator.YinhaiProjectGenerateDto;
import com.sunyy.codegenerator.service.CodeGeneratorService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 模板生成
 *
 * @author sunyy
 * @date 2025/7/10
 */
@Slf4j
@RestController
@RequestMapping("/codeGenerator")
public class CodeGeneratorController {

    @Resource
    private CodeGeneratorService codeGeneratorService;

    /**
     * 银海项目模板代码生成
     *
     * @param dto
     * @param response
     * @return
     */
    @PostMapping("/yinhaiProjectGenerate")
    public String yinhaiProjectGenerate(@RequestBody YinhaiProjectGenerateDto dto, HttpServletResponse response) {
        // codeGeneratorService.yinhaiProjectGenerate(dto, response);
        return "生成到了配置文件配置的地方";
    }

    /**
     * 代码生成
     * 根据分组情况生成指定层级的文件并打成压缩包
     */
    @PostMapping("/generate")
    public void generate(@RequestBody GenerateDto dto, HttpServletResponse response) {
        codeGeneratorService.generate(dto, response);
    }

}
